from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.schedulers.background import BackgroundScheduler

from config import BaseConfig

app_scheduler = None

global app_scheduler

"""
erp和owms的预编译触发器,每个ad的预编译器只允许一个运行.
"""

# app_scheduler = BackgroundScheduler(jobstores={
#     'default': SQLAlchemyJobStore(url=BaseConfig.SQLALCHEMY_DATABASE_URI)
# }, executors={
#     'single': ProcessPoolExecutor(1)
# }, job_defaults={
#     'coalesce': False,
#     'max_instances': 1
# })
#
# app_scheduler.start()


# @app_scheduler.scheduled_job(trigger='interval', executor='process-pool', seconds=60)
# def pre_compile_erp_projects():
#     print("Hello World")
#
#
# @app_scheduler.scheduled_job(trigger='interval', executor='process-pool', seconds=60)
# def pre_compile_owms_projects():
#     print("Hello World")
